﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using FTchina;
public partial class UI_ipchk : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        basic.CheckAdmin(this);
        basic.ChkPoewr(this, FTchina.Api.htmlpath.GetCurrentPagePath());
        try { if (Request["ip"].Length != 0) { txbbip.Text = Request["ip"]; txbeip.Text = Request["ip"]; } }
        catch { }
        if (!IsPostBack)
        {

            GetIpList();
        }
    }
    protected void txbbip_TextChanged(object sender, EventArgs e)
    {
        txbeip.Text = txbbip.Text;
    }
    protected void btnok_Click(object sender, EventArgs e)
    {
        InsertIP();
        GetIpList();
    }
    protected void InsertIP()
    {
        string bip = txbbip.Text;
        string eip = txbeip.Text;
        string InsertSql = "insert into iptable (bip,eip) values ('" + bip + "','" + eip + "')";

        UImsg.PageRender(shujuku.ExecuteSql(InsertSql));
      
        LogNet.LogBLL.info("用户:" + FTchina.Library.MasterHelper.MasterName + "添加IP限制" + bip + "-" + eip);

       

        txbeip.Text = "";
        txbbip.Text = "";
    }
    protected void GetIpList()
    {
        string GetSql = "select * from iptable";
        DataTable dt = shujuku.GetDataTable(GetSql);
        string temphtml = "";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            temphtml += " <tr><td>" + dt.Rows[i]["bip"] + "</td><td>" + dt.Rows[i]["eip"] + "</td><td><a href='/ui/del.aspx?T=iptable&id=" + dt.Rows[i]["id"].ToString() + "' >删除</a></td></tr>";
        }
        litiplist.Text = temphtml;
    }
}
